﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
@section Content{
    <style>
        .topPanel {
            height: 95px;
        }

            .topPanel .search {
                padding-top: 10px;
            }
    </style>
}
@*<div class="topPanel">
        <div class="toolbar">
            <div class="btn-group">
                <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
                <a class="btn btn-default" onclick="$.reload()">自拓场地todo</a>
                <a class="btn btn-default" onclick="btn_highSeas()">公海</a>
            </div>
            <div class="btn-group">
                    <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-eraser"></i>添加按钮</a>
                </div>
                <div class="operate">
                    <ul class="nav nav-pills">
                        <li class="first">已选中<span>1</span>项</li>
                        <li><a id="NF-edit" authorize="yes" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改按钮</a></li>
                        <li><a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除按钮</a></li>
                    </ul>
                    <a href="javascript:;" class="close"></a>
                </div>
                <script>$('.toolbar').authorizeButton()</script>
        </div>
        <div class="search">
        </div>
    </div>*@

<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>


<script>
    // from page type
    var pageType = $.request("type");

    $(function () {
        $("#search_orderState a.btn-default").click(function () {
            $("#search_orderState a.btn-default").removeClass("active");
            $(this).addClass("active");
            $('#btn_search').trigger("click");
        });
        gridList();
    })
    function gridList() {
        var $gridList = $("#gridList");

        $gridList.dataGrid({
            url: "/ClientsData/GetUnreadMessageFromGridJson",
            height: $(window).height()-85,
            colModel: [
                { label: '编号', name: 'F_Id', hidden: true },
                { label: '内容', name: 'F_MessageContent', width: 350, sortable: false, align: 'left' },
                {
                    label: '操作', name: 'F_Id', width: 50, align: 'left', sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        var html = '<div class="btn-group btn-group-xs" style="margin-top:5px;">';
                        html += '   <button type="button" class="btn btn-link" onclick="btn_read(\'' + cellvalue + '\', 0)">已读</button>';
                        html += '</div>';

                        return html;
                    }
                }
            ],
            postData: {

            },
            pager: "#gridPager",
            sortname: 'F_LastModifyTime',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            var queryJson = {
                keyword: $("#txt_keyword").val(), orderstate: $("#search_orderState a.active").attr('data-value'),
            };
            $gridList.jqGrid('setGridParam', {
                postData: { queryJson: JSON.stringify(queryJson) },
            }).trigger('reloadGrid');
        });
    }

    //已读
    function btn_read(id) {

        $.modalConfirm('确认是否已读？', function (flag) {
            if (flag) {
                $.submitForm({
                    url: "/ClientsData/SetMessageForReaded?keyValue=" + id,
                    param: {},
                    close: false,
                    success: function (data) {
                        $("#gridList").trigger("reloadGrid");
                    }
                });
            }
        });
    }


</script>
